<!--#include file="../main/top.asp" -->
<%levelArray = userLevel()%>
<%
	'验证用户名是否重复
	username = request.Form("username")
	sql="select * from cw_users where username = '"&username&"'"
	set rs_username = ado_iquery(sql,conn,1,3)
	if not rs_username.eof then
		rs_username.close : set rs_username=nothing
		conn.close : set conn=nothing
		
		response.write "<script language=javascript>"
		response.write "alert('用户名已存在，请更换用户名！');"
		response.write "document.location='adminUsersAdd.asp';"
		response.write "</script>"
	else
		
		sql="select * from cw_users"
    	set rs = ado_iquery(sql,conn,1,3)
    	rs.addnew
		rs("username")=request.Form("username")
		password = request.Form("password")
		rs("password")=sha1(password)
		rs("realName")=request.Form("realName")
		rs("telNum")=request.Form("telNum")		
		rs("userLevel")=request.Form("userLevel")		
		level=request.Form("userLevel")
		rs("roleCollection") = trim(request.Form("selectRole"))
		echo level
		if level=1 then
			rs("collegeid")=-1
			rs("classCollection")=""
		elseif level=2 then
			rs("collegeid")=request.Form("collegeid")
			rs("classCollection")=""
		elseif level=3 then
			rs("collegeid")=request.Form("collegeid")
			rs("classCollection")=request.Form("classCollection")
		end if
		
		rs.update
		rs.close : set rs=nothing
		conn.close : set conn = nothing

	end if
%>
<div class="function_title"><span class="t2"><img src="../images/dqwz.gif">当前位置：操作提示</span></div>
<div class="function_content">
<div class="return_info">信息添加成功！ <a href="adminUsersAdd.asp">继续添加</a> <a href="adminUsersList.asp">返回列表</a></div>
</div>
<!--#include file="../main/bottom.asp" -->